package com.zs.controller.btrace.script;

import com.zs.common.model.DemoUser;
import org.openjdk.btrace.core.BTraceUtils;
import org.openjdk.btrace.core.annotations.*;

import java.lang.reflect.Field;

/**
 * 打印复杂参数
 */
@BTrace
public class PrintArgComplex {


    @OnMethod(
            clazz = "com.zs.controller.btrace.BtraceController",
            method = "arg2",
            location = @Location(Kind.ENTRY)
    )
    public static void anyRead(@ProbeClassName String pcn, @ProbeMethodName String pmn, DemoUser demoUser) {
        //print all fields
        BTraceUtils.printFields(demoUser);
        //print one field
        Field filed2 = BTraceUtils.field("com.zs.common.model.DemoUser", "name");
        BTraceUtils.println(BTraceUtils.get(filed2, demoUser));
        BTraceUtils.println(pcn + "," + pmn);
        BTraceUtils.println();
    }
}
